<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base],
  components: {
    SelectImageRadio: async () =>
      Vue.extend(
        await Vue.prototype.$vFN.Components.Base.SelectImageRadio()
      ),
  },
  data() {
    return {
      appWindow: window,
      load: false,

      // 基础信息表单
      form: {
        logoImg: "",  // Logo
        name: "",    // 名称
        status: 0,   // 状态
        remark: "", // 简称
      },

      // 页面接口地址
      apiUrl: {
        detail: "mall-site-portal/platform-setting/getItem",
        update: "mall-site-portal/platform-setting/update",
      },

      infoData: null, //基础数据
    };
  },
  methods: {
    // 初始化
    async init() {
      this.load = true;
      this.getDetail();
      this.load = false;
    },

    // 获取设置的数据
    async getDetail() {
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.detail,
        },
        window
      );
      if (res._ok) {
        this.infoData = res.data;

        for (const key in this.form) {
          if (!this.$vFN.Utils.isEmpty(res.data[key])) {
            this.form[key] = res.data[key];
          }
        }
      }
    },
    
    // 保存事件
    async updateBase() {
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.update,
          data: {
            ...this.form,
          },
        },
        window
      );

      if (res._ok) {
        this.$vFN.Tools.messageSuccess(res.message);
        this.init();
      }
    },
  },
  mounted() {
    this.init();
  },

  activated() {},
};
</script>
